#ifndef GFX_H_
#define GFX_H_

/*
	Copyright (C) 2011 Salil Bhagurkar

	This file is part of illusion

	illusion is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as
	published by the Free Software Foundation, either version 3 of
	the License, or (at your option) any later version.

	illusion is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with illusion. 
	If not, see <http://www.gnu.org/licenses/>.
*/

#include <kernel/ilg.h>

#define GE_ROOT 0
#define GE_TEXT 1
#define GE_IMG 2
#define GE_BTN 3

/*
 * The base descriptor of a graphics element.
 */
struct g_element {
	uint eid;
	uint type, x, y;
	struct ilg_header *ilg;
	struct g_element *next, *prev;
	uint child_count;
	struct g_element *parent;
	struct g_element *childs, *childs_tail;
};

#define GD_NAME_LEN 32

struct graphics_mode {
	//Mode id with which the graphics driver can identify the mode
	uint mode_id;
	uint x, y, bits_per_pixel, speed_level;
	struct graphics_driver *driver;
	struct graphics_mode *next, *prev;
};

struct graphics_driver {
	char name[GD_NAME_LEN];
	struct graphics_mode *modes, *modes_tail;
	struct graphics_mode *current_mode;
	int (*flush_buffer)(void *buffer);
	int (*init)();
	int (*get_modes)();
	int (*set_mode)(struct graphics_mode *mode);
	int (*reset_mode)();
	struct graphics_driver *next, *prev;
};

void register_graphics_driver(struct graphics_driver *driver);
void unregister_graphics_driver(struct graphics_driver *driver);

int g_initialize(uint x, uint y);
int g_deinitialize();
int g_flush();

int graphics_sys_init();

#endif /* GFX_H_ */
